package com.taobao.machinesystem.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 开启事务管理
 */
@MapperScan("com.taobao.machinesystem.mapper")
@EnableTransactionManagement
@SpringBootConfiguration
public class MybatisConfiguration {
    /**
     * 配置mybatis-plus的分页插件
     * @return PaginationInterceptor
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }

    /**
     * 乐观锁插件
     * @return OptimisticLockerInterceptor
     * OptimisticLockerInnerInterceptor
     */
    @Bean
    public OptimisticLockerInterceptor OptimisticLockerInnerInterceptor() {
        return new OptimisticLockerInterceptor();
    }
}
